﻿<!--
Copyright (c) 2009, Andreas Grünwald
All rights reserved.
    -->

<Window x:Class="yaTDL.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    DataContext="{Binding RelativeSource={RelativeSource Self}}"
    Title="yaTDL" MinHeight="423" MinWidth="665"
    xmlns:my="clr-namespace:yaTDL" mc:Ignorable="d" 
    xmlns:yaTDL_Settings="clr-namespace:yaTDL.Properties;assembly=yaTDL"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:converters="clr-namespace:yaTDL.Core.Converters;assembly=yaTDL.Core"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
        Height="{Binding MainWindow_WindowHeight, Source={x:Static yaTDL_Settings:UISettings.Default}, Mode=TwoWay}" 
        Width="{Binding MainWindow_WindowWidth, Source={x:Static yaTDL_Settings:UISettings.Default}, Mode=TwoWay}" 
        Top="{Binding MainWindow_Top, Source={x:Static yaTDL_Settings:UISettings.Default}, Mode=TwoWay}"
        Left="{Binding MainWindow_Left, Source={x:Static yaTDL_Settings:UISettings.Default}, Mode=TwoWay}" Background="{x:Null}"
        PreviewKeyDown="Window_PreviewKeyDown">
	
    
    <Window.Resources>

        <converters:VisibilityBoolConverter x:Key="visibilityBoolConverter" />
        
		<Storyboard x:Key="Animation_NavigationFadeIn">
			<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="frame1" Storyboard.TargetProperty="(UIElement.Opacity)">
				<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
				<SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="1" KeySpline="0.08,0,1,0"/>
			</DoubleAnimationUsingKeyFrames>
		</Storyboard>
		<Storyboard x:Key="Animation_NavigationFadeOut">
			<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="frame1" Storyboard.TargetProperty="(UIElement.Opacity)">
				<SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="0"/>
			</DoubleAnimationUsingKeyFrames>
		</Storyboard>       
        
    </Window.Resources>
	
    <Window.InputBindings>
        <KeyBinding Command="{Binding ElementName=frame1,Path=Content.DataContext.ShowSearchViewCommand}" Gesture="CTRL+F" />        
    </Window.InputBindings>
    
    <Border BorderBrush="Gray" BorderThickness="1">
		<Grid Background="White">
            <Frame x:Name="frame1" IsEnabled="{Binding Path=SyncIndicatorVisibilty, Converter={StaticResource visibilityBoolConverter}, ConverterParameter='invert'}" Focusable="False" 
				Margin="0" Content="" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" Grid.IsSharedSizeScope="True" MinWidth="542" NavigationUIVisibility="Hidden" />
            <Grid  Visibility="Collapsed" Margin="0" HorizontalAlignment="Stretch" x:Name="Grid_Overlay" Background="#B1F6F6F6" />           
			
			<!--A overlay displayed whle a sync is running-->
			<Grid Name="syncIndicatorControl" Visibility="{Binding SyncIndicatorVisibilty}" Height="100" HorizontalAlignment="Center" Margin="0" VerticalAlignment="Center" Width="300">				
				<Grid.Resources>
					<!--Definition of the element's animations-->
					<Storyboard x:Key="Storyboard3" RepeatBehavior="Forever">
							<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(ContentControl.Content)" Storyboard.TargetName="label">
							<DiscreteObjectKeyFrame KeyTime="0" Value=""/>
							<DiscreteObjectKeyFrame KeyTime="0:0:0.5" Value="."/>
							<DiscreteObjectKeyFrame KeyTime="0:0:1" Value=".."/>
							<DiscreteObjectKeyFrame KeyTime="0:0:1.5" Value="..."/>
							<DiscreteObjectKeyFrame KeyTime="0:0:2" Value=""/>
						</ObjectAnimationUsingKeyFrames>
					</Storyboard>
					<Storyboard x:Key="Animation_FadeIn">
						<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="syncIndicatorControl">
							<SplineDoubleKeyFrame KeyTime="0" Value="0"/>
							<SplineDoubleKeyFrame KeyTime="0:0:0.5" Value="1"/>
						</DoubleAnimationUsingKeyFrames>
					</Storyboard>
					<Storyboard x:Key="Animation_FadeOut">
						<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="syncIndicatorControl">
							<SplineDoubleKeyFrame KeyTime="0" Value="1"/>
							<SplineDoubleKeyFrame KeyTime="0:0:0.5" Value="0"/>
						</DoubleAnimationUsingKeyFrames>
					</Storyboard>
			
				</Grid.Resources>
				
				<!--Automatically start the animation once the element has been loaded-->
				<Grid.Triggers>
					<EventTrigger RoutedEvent="FrameworkElement.Loaded">
						<BeginStoryboard Storyboard="{StaticResource Storyboard3}"/>
					</EventTrigger>
				</Grid.Triggers>
				
				<!--The element's background-->
				<Grid.Background>
					<RadialGradientBrush RadiusY="0.479" RadiusX="0.389">
						<GradientStop Color="White" Offset="0.418"/>
						<GradientStop Offset="1"/>
					</RadialGradientBrush>
				</Grid.Background>
				
				<!--The actual content being displayed-->
				<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Height="64" Width="139.332" Orientation="Horizontal">
					<Label Content="Syncing" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" FontSize="29.333"/>
					<Label Content="..." VerticalContentAlignment="Center" Name="label" FontSize="29.333" Padding="0,5,5,5"/>
				</StackPanel>		
			</Grid>
			
		</Grid>
	</Border>
</Window>
